package org.penguin.study.bk.base.api

import com.baomidou.mybatisplus.annotation.TableLogic
import com.fasterxml.jackson.annotation.JsonInclude
import io.swagger.v3.oas.annotations.media.Schema
import lombok.Getter
import lombok.Setter
import java.io.Serializable
import java.time.LocalDateTime
import javax.persistence.MappedSuperclass
import javax.persistence.Version

@Getter
@Setter
@MappedSuperclass
open class UUIDEntity : Serializable {

    @Version
    @Schema(title = "消息版本")
    var version: Long? = null

    @Schema(title = "删除标志")
    @TableLogic
    private val deleted: Int? = null

    /**
     * 由于配置了spring.factories，所以不用再配置了，除非有特殊需求
     */
//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(title = "消息创建时间", pattern = "yyyy-MM-dd HH:mm:ss")
    var createdTime: LocalDateTime? = null

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Schema(title = "消息创建人")
    var createdBy: String? = null

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Schema(title = "消息修改人")
    var updatedBy: String? = null

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Schema(title = "消息修改时间", pattern = "yyyy-MM-dd HH:mm:ss")
    var updatedTime: LocalDateTime? = null

    companion object {
        private const val serialVersionUID = 1L
    }
}